package com.box.controller.searchcontroller;

import com.box.service.search.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.box.service.search.SearchBlogService;
import com.box.utils.ResponseResult;

/**   
*    
* 项目名称：MyBox   
* 类名称：ImportSolrjController   
* 类描述：   导入博客数据到索引数据库中的控制器
* 创建人：君无邪   
* 创建时间：2019年11月20日 下午3:27:29   
* 修改备注：  https://www.java214.com 
* @version    1.0
*    
*/ 
@Controller
@RequestMapping("/solrj")
public class ImportSolrjController {
	
	@Autowired
	private SearchBlogService importService;

	@Autowired
	private SearchService searchService;
	
	@RequestMapping("/importall")
	@ResponseBody
	public ResponseResult importAll(){
		try {
			ResponseResult importBlog = importService.importBlog();
			return importBlog;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return ResponseResult.build(500,e+"");
		}
	}

	@RequestMapping("/delId/{id}")
	@ResponseBody
	public ResponseResult DeleteById(@PathVariable("id") Integer id){

		try {
			ResponseResult importBlog = searchService.deletById(id);
			return importBlog;
		} catch (Exception e) {
			// TODO: handle exception
			e.printStackTrace();
			return ResponseResult.build(500,e+"");
		}
	}

}
